Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct handling of Datasets #1845

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Conversation

Qup42
Copy link
Member

@Qup42 Qup42 commented Feb 28, 2025

  • Add tests for dataset handling of visitor (is the current dataset propagated into contained EXISTS) in SparqlAntlrParserTest`. Previously this was only tested indirectly in the QueryPlanerTest.
    • Fixed that the active datasets were not propagated in Modify.
  • Some refactoring of matchers. Of the code blocks that had to be moved only the Describe matcher was changed slightly (it now matcher GraphPattern for consistence with the other matchers).
  • SparqlQleverVisitor takes the override dataset clause in its constructor and if these contain datasets then the datasets in the query are ignored.
    • Some accompanying tests in SparqlParserTest.

TODO:

  • the Datasets are defaulted to empty in some layers of the call stack. Keep as few as possible, those at higher layers preferred.
  • the new tests for DESCRIBE currently fail, because the datasets are not set in its contained select (code comments seem to indicate that this should be set)
  • finalize the override implementation in the visitor (implicit by being empty vs explicit with an extra field)

Copy link
Member Author

@Qup42 Qup42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite finished yet, but we can already do an initial round.

Comment on lines +2339 to +2345
expectDescribe(
"Describe ?x FROM <g> { ?x ?y ?z FILTER EXISTS {?a ?b ?c}}",
m::DescribeQuery(
m::Describe({Var("?x")}, {datasets, {}},
m::SelectQuery(m::VariablesSelect({"?x"}, false, false),
filterGraphPattern, datasets)),
datasets));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test (and the equivalent one in SparqlParserTest) currently fail because the Select doesn't have the datasets set. This seems to be the desired behaviour (SparqlQleverVisitor.cpp::398):

NOTE: The dataset clauses are stored once in parsedQuery_.datasetClauses_ (which pertains to the CONSTRUCT query that computes the result of the DESCRIBE), and once in parsedQuery_.describeClause_.datasetClauses_ (which pertains to the SELECT query that computes the resources to be described).

If that is so, then this note should be extended by this fact.

Comment on lines +324 to +330
// TODO: is it a good idea to do this implicitly (the fields are nullopt) or
// should this be done explicitly (with a bool flag)?
if (!activeDatasetClauses_.defaultGraphs_.has_value() &&
!activeDatasetClauses_.namedGraphs_.has_value()) {
activeDatasetClauses_ = parsedQuery::DatasetClauses::fromClauses(clauses);
}
return activeDatasetClauses_;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: finish

Copy link

sonarqubecloud bot commented Mar 4, 2025

@sparql-conformance
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant